#! /bin/sh

DAEMON_FILE="hippo_imp_daemon.sh"
CFG_FILE="hippo_imp_cfg"

[ ! -f "$DAEMON_FILE" ] && echo "File $DAEMON_FILE not exists!exit" && exit 1
[ ! -f "$CFG_FILE" ] && echo "File $CFG_FILE not exists!exit" && exit 1
sed 's///g' < "$DAEMON_FILE" > tmpfile1
sed 's///g' < "$CFG_FILE" > tmpfile2
mv tmpfile1 "$DAEMON_FILE"
mv tmpfile2 "$CFG_FILE"

chmod 744 "$DAEMON_FILE"
chmod 644 "$CFG_FILE"
echo "starting daemon $DAEMON_FILE......"
echo
nohup ./"$DAEMON_FILE" > hippo_imp.out 2>&1 &
sleep 2
if ps -ef | grep "$DAEMON_FILE" | grep -v grep ; then
  echo
  echo "done!"
fi
exit 0
